package algorithms.sorting;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.Arrays;

import org.junit.Test;

public class BubbleSortingTest {

	@Test
	public void testSimpleCase() {
		int[] simpleCase = new int[] { 8, 5, 4, 1 };

		Sorter bubbleSorting = new BubbleSorting();
		int[] sorted = bubbleSorting.sort(simpleCase);
		assertTrue(Arrays.equals(new int[] { 1, 4, 5, 8 }, sorted));
	}

	@Test
	public void testOneElement() {
		int[] simpleCase = new int[] { 8 };

		Sorter bubbleSorting = new BubbleSorting();
		int[] sorted = bubbleSorting.sort(simpleCase);
		assertTrue(Arrays.equals(new int[] { 8 }, sorted));
	}

	@Test
	public void testNull() {
		Sorter bubbleSorting = new BubbleSorting();
		try {
			bubbleSorting.sort(null);
			fail("IllegalArgumentException  expected!");
		} catch (IllegalArgumentException e) {
		}
	}
}
